<template>
  <div>
    <!-- 查询模块 -->
    <el-form :model="dataParams" ref="queryForm" size="medium" :inline="true" label-width="80px">
      <el-form-item label="维修记录" prop="repairNume">
        <el-input v-model="dataParams.repairNume" placeholder="请输入维修单编号" clearable @keyup.enter.native="getList" />
      </el-form-item>
      <el-form-item label="" prop="createBy">
        <el-input v-model="dataParams.createBy" placeholder="请输入报障人" clearable @keyup.enter.native="getList" />
      </el-form-item>
      <el-form-item label="" prop="repairerNames">
        <el-input v-model="dataParams.repairerNames" placeholder="请输入处理人" clearable @keyup.enter.native="getList" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="medium" @click="getList">
          搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格模块 -->
    <el-table v-loading="loading" :data="noticeList">
      <el-table-column label="序号" align="center" min-width="50">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="维修编号" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.repairNum || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="报障时间" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.createTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="报障人" align="center" min-width="130">
        <template slot-scope="scope">
          {{ scope.row.createBy || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="故障类型" align="center" min-width="150" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.faultTypeName || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="故障等级" align="center" min-width="120">
        <template slot-scope="scope">
          {{ ['紧急', '严重', '一般'][scope.row.faultLevel] || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="故障描述" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.faultDescribe || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="故障原因" align="center" min-width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.faultReason || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="预防措施" align="center" min-width="180">
        <template slot-scope="scope">
          {{ scope.row.precaution || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="分派状态" align="center" min-width="130">
        <template slot-scope="scope">
          {{ ['待分派', '已分派'][scope.row.assignStatus] || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="维修状态" align="center" min-width="130">
        <template slot-scope="scope">
          <dict-tag :options="repairStatus" :value="scope.row.repairStatus" />
        </template>
      </el-table-column>
      <el-table-column label="处理人" align="center" min-width="150" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ scope.row.repairerNames || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="维修完成时间" align="center" min-width="150">
        <template slot-scope="scope">
          {{ scope.row.repairTime || '-' }}
        </template>
      </el-table-column>
      <el-table-column label="维修方式" align="center" min-width="130">
        <template slot-scope="scope">
          {{ ['自修', '委外'][scope.row.repairMode] || '-' }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import { getrepairlist } from "@/api/equipment/equipment.js";
export default {
  name: 'repair',
  props: ['rowObj'],
  data () {
    return {
      total: 0,
      loading: false,
      noticeList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderByColumn: 'repairId',
        isAsc: 'desc'//倒叙
      },
      dataParams: {
        repairNume: null,
        createBy: null,
        repairerNames: null
      }
    }
  },
  created () {
    this.getList()
  },
  methods: {
    /**初始化表格数据 */
    async getList () {
      this.loading = true
      let params = {
        ...this.queryParams,
        ...this.dataParams,
        equipmentAccountId: this.rowObj.equipmentAccountId
      }
      let data = await getrepairlist(params);
      this.total = data.total
      this.noticeList = data.data
      this.loading = false
    },
    /**
     * 重置查询表单
     */
    resetQuery () {
      for (const key in this.dataParams) {
        this.dataParams[key] = null
      }
    }
  }
}
</script>

<style>
</style>